package com.cjy.pojo;

import java.io.Serializable;

public class SystemResult implements Serializable {

    private Integer code;

    private String msg;

    private Object data;

    public static SystemResult ok(Object data){
        SystemResult systemResult = new SystemResult();
        systemResult.setCode(200);
        systemResult.setMsg("请求成功");
        systemResult.setData(data);
        return systemResult;
    }

    public static SystemResult err(Object data){
        SystemResult systemResult = new SystemResult();
        systemResult.setCode(500);
        systemResult.setMsg("请求失败");
        systemResult.setData(data);
        return systemResult;
    }

    public static SystemResult err(){
        SystemResult systemResult = new SystemResult();
        systemResult.setCode(500);
        systemResult.setMsg("请求失败");
        systemResult.setData(null);
        return systemResult;
    }
    public static SystemResult getResult(int code, String msg,Object data){
        return new SystemResult(code,msg,data);
    }

    public SystemResult() {
    }

    public SystemResult(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "SystemResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
